home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 940 b | 43 lines | [TEXT/CWIE] |
- // Commander.h
-
- #ifndef Commander_h
- #define Commander_h
-
- #ifndef Assert_h
- #include "Assert.h"
- #endif
- #ifndef ContextMaintainer_h
- #include "ContextMaintainer.h"
- #endif
- #ifndef CommandLink_h
- #include "CommandLink.h"
- #endif
-
- template < class Protocol >
- class Commander
- {
- typedef CommandLink< Protocol > LinkType;
-
- private:
- ContextMaintainer oldContext;
-
- public:
- Commander()
- : oldContext( *LinkType::ActiveHandler() )
- {
- Assert( LinkType::ActiveHandler() != 0 );
- }
-
- Protocol& operator*() { Assert( !Null() ); return *LinkType::ActiveHandler(); }
-
- Protocol *operator->() { Assert( !Null() ); return LinkType::ActiveHandler(); }
-
- const Protocol& operator*() const { Assert( !Null() ); return *LinkType::ActiveHandler(); }
-
- const Protocol *operator->() const { Assert( !Null() ); return LinkType::ActiveHandler(); }
-
- static bool Null() { return LinkType::ActiveHandler() == 0; }
- };
-
- #endif
-